home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / map.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  24.4 KB  |  704 lines

  1. #ifndef __STD_MAP__
  2. #define __STD_MAP__
  3. #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * map - declarations for the Standard Library map class
  8.  *
  9.  * $Id: map,v 1.47 1996/09/11 23:03:17 smithey Exp $
  10.  *
  11.  ***************************************************************************
  12.  *
  13.  * Copyright (c) 1994
  14.  * Hewlett-Packard Company
  15.  *
  16.  * Permission to use, copy, modify, distribute and sell this software
  17.  * and its documentation for any purpose is hereby granted without fee,
  18.  * provided that the above copyright notice appear in all copies and
  19.  * that both that copyright notice and this permission notice appear
  20.  * in supporting documentation.  Hewlett-Packard Company makes no
  21.  * representations about the suitability of this software for any
  22.  * purpose.  It is provided "as is" without express or implied warranty.
  23.  *
  24.  *
  25.  ***************************************************************************
  26.  *
  27.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  28.  * ALL RIGHTS RESERVED *
  29.  * The software and information contained herein are proprietary to, and
  30.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  31.  * intends to preserve as trade secrets such software and information.
  32.  * This software is furnished pursuant to a written license agreement and
  33.  * may be used, copied, transmitted, and stored only in accordance with
  34.  * the terms of such license and with the inclusion of the above copyright
  35.  * notice.  This software and information or any other copies thereof may
  36.  * not be provided or otherwise made available to any other person.
  37.  *
  38.  * Notwithstanding any other lease or license that may pertain to, or
  39.  * accompany the delivery of, this computer software and information, the
  40.  * rights of the Government regarding its use, reproduction and disclosure
  41.  * are as set forth in Section 52.227-19 of the FARS Computer
  42.  * Software-Restricted Rights clause.
  43.  * 
  44.  * Use, duplication, or disclosure by the Government is subject to
  45.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  46.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  47.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  48.  * P.O. Box 2328, Corvallis, Oregon 97339.
  49.  *
  50.  * This computer software and information is distributed with "restricted
  51.  * rights."  Use, duplication or disclosure is subject to restrictions as
  52.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  53.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  54.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  55.  * then the "Alternate III" clause applies.
  56.  *
  57.  **************************************************************************/
  58.  
  59. #include <stdcomp.h>
  60.  
  61. #ifdef __BORLANDC__
  62. #pragma option -w-inl
  63. #endif
  64.  
  65. #ifndef _RWSTD_HEADER_REQUIRES_HPP
  66. #include <memory>
  67. #include <functional>
  68. #include <rw/tree>
  69. #else
  70. #include <memory.hpp>
  71. #include <functional.hpp>
  72. #include "rw/tree.hpp"
  73. #endif
  74.  
  75. #ifndef _RWSTD_NO_NAMESPACE
  76. namespace __rwstd {
  77. #endif
  78.  
  79. //
  80. // This is used in the implementation of map and multimap.
  81. //
  82.  
  83. template <class T, class U>
  84. struct select1st : public unary_function<T, U>
  85. {
  86.     const U& operator() (const T& x) const { return x.first; }
  87. };
  88.  
  89. #ifndef _RWSTD_NO_NAMESPACE
  90. }
  91.  
  92. namespace std {
  93. #endif
  94.  
  95. //
  96. // First the map stuff.
  97. //
  98.   
  99. //
  100. // Note that _RWSTD_SIMPLE_DEFAULT(x) and _RWSTD_COMPLEX_DEFAULT(x)
  101. // will expand to: ' = x', or nothing,
  102. // depending on your compiler's capabilities and/or
  103. // flag settings (see stdcomp.h).
  104. //
  105. template <class Key, class T, 
  106.           class Compare _RWSTD_COMPLEX_DEFAULT(less<Key>), 
  107.           class Allocator _RWSTD_SIMPLE_DEFAULT(allocator<T>) >
  108. class map
  109. {
  110.   public:
  111.     //
  112.     // types
  113.     //
  114.     typedef Key                key_type;
  115. #ifndef _RWSTD_NO_CONST_INST
  116.     typedef pair<const Key, T> value_type;
  117. #else
  118.     typedef pair<Key, T>       value_type;
  119. #endif
  120.     typedef Compare            key_compare;
  121.     typedef Allocator          allocator_type;
  122.     typedef T                  mapped_type;
  123.     typedef T                  referent_type;
  124.     
  125.     class value_compare : public binary_function<value_type, value_type, bool>
  126.     {
  127.         friend class map<Key, T, Compare, Allocator>;
  128.       protected:
  129.         Compare _RWSTD_COMP;
  130.         value_compare (Compare c) : _RWSTD_COMP(c) {}
  131.       public:
  132.         bool operator() (const value_type& x, const value_type& y) const
  133.         {
  134.             return _RWSTD_COMP(x.first, y.first);
  135.         }
  136.     };
  137.  
  138.   private:
  139.     
  140.     typedef __RWSTD::rb_tree<key_type, value_type,
  141.                     __RWSTD::select1st<value_type, key_type>, 
  142.                     key_compare, allocator_type> rep_type;
  143.     rep_type t;
  144.  
  145.   public:
  146.     //
  147.     // types
  148.     //
  149.     typedef _TYPENAME rep_type::reference                reference;
  150.     typedef _TYPENAME rep_type::const_reference          const_reference;
  151.     typedef _TYPENAME rep_type::iterator                 iterator;
  152.     typedef _TYPENAME rep_type::const_iterator           const_iterator;
  153.     typedef _TYPENAME rep_type::size_type                size_type;
  154.     typedef _TYPENAME rep_type::difference_type          difference_type;
  155.     typedef _TYPENAME rep_type::reverse_iterator         reverse_iterator;
  156.     typedef _TYPENAME rep_type::const_reverse_iterator   const_reverse_iterator;
  157.  
  158.     //
  159.     // construct/copy/destroy
  160.     //
  161.     _EXPLICIT map (const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  162.                   const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) 
  163.       : t(_RWSTD_COMP, false, alloc) {}
  164.  
  165. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  166.     map (void) 
  167.       : t(Compare(), false, Allocator()) {}
  168.  
  169.     _EXPLICIT map (const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()))
  170.       : t(_RWSTD_COMP, false, Allocator()) {}
  171. #endif
  172.  
  173. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  174.     template<class InputIterator>
  175.     map (InputIterator first, InputIterator last, 
  176.          const Compare& comp = Compare(),
  177.          const Allocator& alloc = Allocator())
  178.       : t(first, last, comp, false, alloc) {}
  179. #else
  180.     map (const value_type* first, const value_type* last, 
  181.          const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  182.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  183.       : t(first, last, _RWSTD_COMP, false, alloc) {}
  184.     map (iterator first, iterator last, 
  185.          const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  186.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  187.       : t(first, last, _RWSTD_COMP, false, alloc) {}
  188.     map (const_iterator first, const_iterator last, 
  189.          const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  190.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  191.       : t(first, last, _RWSTD_COMP, false, alloc) {}
  192. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  193.     map (const value_type* first, const value_type* last)
  194.       : t(first, last, Compare(), false, Allocator()) {}
  195.     map (const value_type* first, const value_type* last, 
  196.          const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()))
  197.       : t(first, last, _RWSTD_COMP, false, Allocator()) {}
  198.  
  199.     map (iterator first, iterator last)
  200.       : t(first, last, Compare(), false, Allocator()) {}
  201.     map (iterator first, iterator last, 
  202.          const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()))
  203.       : t(first, last, _RWSTD_COMP, false, Allocator()) {}
  204.  
  205.     map (const_iterator first, const_iterator last) : t(first, last, Compare(), false, Allocator()) {}
  206.     map (const_iterator first, const_iterator last, 
  207.          const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()))
  208.       : t(first, last, _RWSTD_COMP, false, Allocator()) {}
  209. #endif
  210. #endif
  211.  
  212.     map (const map<Key, T, Compare, Allocator>& x) : t(x.t, false) {}
  213.     map<Key, T, Compare, Allocator>& 
  214.          operator= (const map<Key, T, Compare, Allocator>& x)
  215.     {
  216.           t = x.t; return *this; 
  217.     }
  218.     allocator_type get_allocator() const
  219.     {
  220.         return t.get_allocator();
  221.     }
  222.  
  223.     //
  224.     // iterators
  225.     //
  226.  
  227.     iterator               begin  ()       { return t.begin();  }
  228.     const_iterator         begin  () const { return t.begin();  }
  229.     iterator               end    ()       { return t.end();    }
  230.     const_iterator         end    () const { return t.end();    }
  231.     reverse_iterator       rbegin ()       { return t.rbegin(); }
  232.     const_reverse_iterator rbegin () const { return t.rbegin(); }
  233.     reverse_iterator       rend   ()       { return t.rend();   }
  234.     const_reverse_iterator rend   () const { return t.rend();   }
  235.  
  236.     //
  237.     // capacity
  238.     //
  239.     bool      empty    () const { return t.empty();    }
  240.     size_type size     () const { return t.size();     }
  241.     size_type max_size () const { return t.max_size(); }
  242.  
  243.     //
  244.     // element access
  245.     //
  246.     mapped_type& operator[] (const key_type& k)
  247.     {
  248.         value_type tmp(k,T()); return (*((insert(tmp)).first)).second;
  249.     }
  250.     //
  251.     // TODO - fix this once required functionality is specified by WP!!!
  252.     //
  253.     //const mapped_type& operator[] (const key_type& k) const
  254.     //{
  255.     //    value_type tmp(k,T()); return (*((insert(tmp)).first)).second;
  256.     //}
  257.     //
  258.     // modifiers
  259.     //
  260. #ifndef _RWSTD_NO_RET_TEMPLATE
  261.     pair<iterator,bool> insert (const value_type& x) { return t.insert(x); }
  262. #else
  263.     typedef pair<iterator, bool> pair_iterator_bool; 
  264.     //
  265.     // typedef done to get around compiler bug
  266.     //
  267.     pair_iterator_bool insert (const value_type& x) { return t.insert(x); }
  268. #endif
  269.     iterator insert (iterator position, const value_type& x)
  270.     {
  271.         return t.insert(position, x);
  272.     }
  273.  
  274. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  275.     template<class InputIterator>
  276.     void insert (InputIterator first, InputIterator last)
  277.     {
  278.         t.insert(first, last);
  279.     }
  280. #else
  281.     void insert (const value_type* first, const value_type* last)
  282.     {
  283.         t.insert(first, last);
  284.     }
  285.     void insert (iterator first, iterator last)
  286.     {
  287.         t.insert(first, last);
  288.     }
  289.     void insert (const_iterator first, const_iterator last)
  290.     {
  291.         t.insert(first, last);
  292.     }
  293. #endif
  294.  
  295.     iterator  erase (iterator position)             { return t.erase(position);    }
  296.     size_type erase (const key_type& x)             { return t.erase(x);    }
  297.     iterator  erase (iterator first, iterator last) { return t.erase(first,last); }
  298.     void      clear ()                              { erase(begin(),end()); }
  299.     void      swap  (map<Key, T, Compare, Allocator>& x)       
  300.     { t.swap(x.t);          }
  301.  
  302.     //
  303.     // observers
  304.     //
  305.     key_compare key_comp () const { return t.key_comp(); }
  306.     value_compare value_comp () const { return value_compare(t.key_comp()); }
  307.  
  308.     //
  309.     // map operations
  310.     //
  311.     iterator       find (const key_type& x)        { return t.find(x);        }
  312.     const_iterator find (const key_type& x)  const { return t.find(x);        }
  313.     size_type      count (const key_type& x) const { return t.count(x);       }
  314.     iterator       lower_bound (const key_type& x) { return t.lower_bound(x); }
  315.     iterator       upper_bound (const key_type& x) { return t.upper_bound(x); }
  316.     const_iterator lower_bound (const key_type& x) const
  317.     {
  318.         return t.lower_bound(x); 
  319.     }
  320.     const_iterator upper_bound (const key_type& x) const
  321.     {
  322.         return t.upper_bound(x); 
  323.     }
  324. #ifndef _RWSTD_NO_RET_TEMPLATE
  325.     pair<iterator,iterator> equal_range (const key_type& x)
  326. #else
  327.     typedef pair<iterator, iterator> pair_iterator_iterator; 
  328.     //
  329.     // typedef done to get around compiler bug
  330.     //
  331.     pair_iterator_iterator equal_range (const key_type& x)
  332. #endif
  333.     {
  334.         return t.equal_range(x);
  335.     }
  336. #ifndef _RWSTD_NO_RET_TEMPLATE
  337.     pair<const_iterator, const_iterator> equal_range (const key_type& x) const
  338. #else
  339.     typedef pair<const_iterator, const_iterator> pair_citerator_citerator; 
  340.     //
  341.     // typedef done to get around compiler bug
  342.     //
  343.     pair_citerator_citerator equal_range (const key_type& x) const
  344. #endif
  345.     {
  346.         return t.equal_range(x);
  347.     }
  348.  
  349. #ifndef _RWSTD_STRICT_ANSI
  350.     // Non-standard function for setting buffer allocation size
  351.     size_type allocation_size() { return t.allocation_size(); }
  352.     size_type allocation_size(size_type new_size) 
  353.     { 
  354.        return t.allocation_size(new_size);
  355.     }
  356. #endif  
  357. };
  358.   
  359. //
  360. // Note that _RWSTD_SIMPLE_DEFAULT(x) and _RWSTD_COMPLEX_DEFAULT(x)
  361. // will expand to: ' = x', or nothing,
  362. // depending on your compiler's capabilities and/or
  363. // flag settings (see stdcomp.h).
  364. //
  365. template <class Key, class T, 
  366.           class Compare _RWSTD_COMPLEX_DEFAULT(less<Key>), 
  367.           class Allocator _RWSTD_SIMPLE_DEFAULT(allocator<T>) >
  368. class multimap
  369. {
  370.   public:
  371.     //
  372.     // types
  373.     //
  374.     typedef Key                  key_type;
  375. #ifndef _RWSTD_NO_CONST_INST
  376.     typedef pair<const Key, T>   value_type;
  377. #else
  378.     typedef pair<Key, T>         value_type;
  379. #endif
  380.     typedef Compare              key_compare;
  381.     typedef Allocator            allocator_type;
  382.     typedef T                    mapped_type;
  383.     typedef T                    referent_type;
  384.  
  385.     class value_compare : public binary_function<value_type, value_type, bool>
  386.     {
  387.         friend class multimap<Key, T, Compare, Allocator>;
  388.       protected:
  389.         Compare _RWSTD_COMP;
  390.         value_compare (Compare c) : _RWSTD_COMP(c) {}
  391.       public:
  392.         bool operator() (const value_type& x, const value_type& y) const
  393.         {
  394.             return _RWSTD_COMP(x.first, y.first);
  395.         }
  396.     };
  397.  
  398.   private:
  399.     
  400.     typedef __RWSTD::rb_tree<key_type, value_type, 
  401.                     __RWSTD::select1st<value_type, key_type>, 
  402.                     key_compare, allocator_type> rep_type;
  403.     rep_type t;
  404.  
  405.   public:
  406.     //
  407.     // types
  408.     //
  409.     typedef _TYPENAME rep_type::reference                reference;
  410.     typedef _TYPENAME rep_type::const_reference          const_reference;
  411.     typedef _TYPENAME rep_type::iterator                 iterator;
  412.     typedef _TYPENAME rep_type::const_iterator           const_iterator; 
  413.     typedef _TYPENAME rep_type::size_type                size_type;
  414.     typedef _TYPENAME rep_type::difference_type          difference_type;
  415.     typedef _TYPENAME rep_type::reverse_iterator         reverse_iterator;
  416.     typedef _TYPENAME rep_type::const_reverse_iterator   const_reverse_iterator;
  417.     //
  418.     // construct/copy/destroy
  419.     //
  420.     _EXPLICIT multimap (const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  421.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) 
  422.        : t(_RWSTD_COMP, true, alloc) { }
  423.  
  424. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  425.     multimap (void) 
  426.        : t(Compare(), true, Allocator()) { }
  427.     _EXPLICIT multimap (const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()))
  428.        : t(_RWSTD_COMP, true, Allocator()) { }
  429. #endif
  430.  
  431. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  432.     template<class InputIterator>
  433.     multimap (InputIterator first, InputIterator last, 
  434.               const Compare& comp = Compare(),
  435.          const Allocator& alloc = Allocator()) 
  436.       : t(first, last, comp, true, alloc) { }
  437. #else
  438.     multimap (const value_type* first, const value_type* last, 
  439.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  440.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  441.       : t(first, last, _RWSTD_COMP, true, alloc) { }
  442.     multimap (iterator first, iterator last,
  443.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  444.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  445.       : t(first, last, _RWSTD_COMP, true, alloc) { }
  446.     multimap (const_iterator first, const_iterator last,
  447.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  448.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  449.       : t(first, last, _RWSTD_COMP, true, alloc) { }
  450. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  451.     multimap (const value_type* first, const value_type* last)
  452.       : t(first, last, Compare(), true, Allocator()) { }
  453.     multimap (const value_type* first, const value_type* last, 
  454.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()))
  455.       : t(first, last, _RWSTD_COMP, true, Allocator()) { }
  456.  
  457.     multimap (iterator first, iterator last)
  458.       : t(first, last, Compare(), true, Allocator()) { }
  459.     multimap (iterator first, iterator last,
  460.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()))
  461.       : t(first, last, _RWSTD_COMP, true, Allocator()) { }
  462.  
  463.     multimap (const_iterator first, const_iterator last)
  464.       : t(first, last, Compare(), true, Allocator()) { }
  465.     multimap (const_iterator first, const_iterator last,
  466.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()))
  467.       : t(first, last, _RWSTD_COMP, true, Allocator()) { }
  468. #endif
  469. #endif
  470.  
  471.     multimap (const multimap<Key, T, Compare, Allocator>& x) : t(x.t, true) { }
  472.     multimap<Key, T, Compare, Allocator>& 
  473.             operator= (const multimap<Key, T, Compare, Allocator>& x)
  474.     {
  475.           t = x.t; return *this; 
  476.     }
  477.     allocator_type get_allocator() const
  478.     {
  479.         return t.get_allocator();
  480.     }
  481.  
  482.     //
  483.     // iterators
  484.     //
  485.     iterator                 begin  ()       { return t.begin();  }
  486.     const_iterator           begin  () const { return t.begin();  }
  487.     iterator                 end    ()       { return t.end();    }
  488.     const_iterator           end    () const { return t.end();    }
  489.     reverse_iterator         rbegin ()       { return t.rbegin(); }
  490.     const_reverse_iterator   rbegin () const { return t.rbegin(); }
  491.     reverse_iterator         rend   ()       { return t.rend();   }
  492.     const_reverse_iterator   rend   () const { return t.rend();   }
  493.  
  494.     //
  495.     // capacity
  496.     //
  497.     bool        empty   () const { return t.empty();    }
  498.     size_type   size    () const { return t.size();     }
  499.     size_type   max_size() const { return t.max_size(); }
  500.  
  501.     //
  502.     // modifiers
  503.     //
  504.     iterator insert (const value_type& x) { return t.insert(x).first; }
  505.     iterator insert (iterator position, const value_type& x)
  506.     {
  507.         return t.insert(position, x);
  508.     }
  509.  
  510. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  511.     template<class InputIterator>
  512.     void insert (InputIterator first, InputIterator last)
  513.     {
  514.         t.insert(first, last);
  515.     }
  516. #else
  517.     void insert (const value_type* first, const value_type* last)
  518.     {
  519.         t.insert(first, last);
  520.     }
  521.     void insert (iterator first, iterator last)
  522.     {
  523.         t.insert(first, last);
  524.     }
  525.     void insert (const_iterator first, const_iterator last)
  526.     {
  527.         t.insert(first, last);
  528.     }
  529. #endif
  530.  
  531.     iterator  erase (iterator position)             { return t.erase(position);    }
  532.     size_type erase (const key_type& x)             { return t.erase(x);    }
  533.     iterator  erase (iterator first, iterator last) { return t.erase(first, last); }
  534.     void      clear ()                              { erase(begin(),end()); }
  535.     void      swap  (multimap<Key, T, Compare, Allocator>& x)  
  536.     { t.swap(x.t);          }
  537.  
  538.     //
  539.     // observers
  540.     //
  541.     key_compare   key_comp   () const { return t.key_comp();                }
  542.     value_compare value_comp () const { return value_compare(t.key_comp()); }
  543.  
  544.     //
  545.     // map operations
  546.     //
  547.     iterator        find (const key_type& x)        { return t.find(x);      }
  548.     const_iterator  find (const key_type& x)  const { return t.find(x);      }
  549.     size_type       count (const key_type& x) const { return t.count(x);     }
  550.     iterator        lower_bound (const key_type& x) {return t.lower_bound(x);}
  551.     iterator        upper_bound (const key_type& x) {return t.upper_bound(x);}
  552.     const_iterator  lower_bound (const key_type& x) const
  553.     {
  554.         return t.lower_bound(x); 
  555.     }
  556.     const_iterator  upper_bound (const key_type& x) const
  557.     {
  558.         return t.upper_bound(x); 
  559.     }
  560. #ifndef _RWSTD_NO_RET_TEMPLATE
  561.     pair<iterator,iterator> equal_range (const key_type& x)
  562. #else
  563.     typedef  pair<iterator, iterator> pair_iterator_iterator; 
  564.     //
  565.     // typedef done to get around compiler bug
  566.     //
  567.     pair_iterator_iterator equal_range (const key_type& x)
  568. #endif
  569.     {
  570.         return t.equal_range(x);
  571.     }
  572. #ifndef _RWSTD_NO_RET_TEMPLATE
  573.     pair<const_iterator,const_iterator> equal_range (const key_type& x) const
  574. #else
  575.     typedef  pair<const_iterator, const_iterator> pair_citerator_citerator; 
  576.     //
  577.     // typedef done to get around compiler bug
  578.     //
  579.     pair_citerator_citerator equal_range (const key_type& x) const
  580. #endif
  581.     {
  582.         return t.equal_range(x);
  583.     }
  584.  
  585. #ifndef _RWSTD_STRICT_ANSI
  586.     // Non-standard function for setting buffer allocation size
  587.     size_type allocation_size() { return t.allocation_size(); }
  588.     size_type allocation_size(size_type new_size) 
  589.     { 
  590.        return t.allocation_size(new_size);
  591.     }
  592. #endif  
  593. };
  594.  
  595. template <class Key, class T, class Compare, class Allocator>
  596. inline bool operator== (const map<Key, T, Compare, Allocator>& x,
  597.                         const map<Key, T, Compare, Allocator>& y)
  598. {
  599.     return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
  600. }
  601.  
  602. template <class Key, class T, class Compare, class Allocator>
  603. inline bool operator< (const map<Key, T, Compare, Allocator>& x, 
  604.                        const map<Key, T, Compare, Allocator>& y)
  605. {
  606.     return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
  607. }
  608.  
  609. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  610. template <class Key, class T, class Compare, class Allocator>
  611. inline bool operator!= (const map<Key,T,Compare,Allocator>& x, 
  612.                         const map<Key,T,Compare,Allocator>& y)
  613. {
  614.     return !(x == y);
  615. }
  616.  
  617. template <class Key, class T, class Compare, class Allocator>
  618. inline bool operator> (const map<Key,T,Compare,Allocator>& x, 
  619.                        const map<Key,T,Compare,Allocator>& y)
  620. {
  621.     return y < x;
  622. }
  623.  
  624. template <class Key, class T, class Compare, class Allocator>
  625. inline bool operator>= (const map<Key,T,Compare,Allocator>& x, 
  626.                         const map<Key,T,Compare,Allocator>& y)
  627. {
  628.     return !(x < y);
  629. }
  630.  
  631. template <class Key, class T, class Compare, class Allocator>
  632. inline bool operator<= (const map<Key,T,Compare,Allocator>& x, 
  633.                         const map<Key,T,Compare,Allocator>& y)
  634. {
  635.     return !(y <  x);
  636. }
  637.  
  638. template <class Key, class T, class Compare, class Allocator>
  639. void swap(map<Key,T,Compare,Allocator>& a, 
  640.           map<Key,T,Compare,Allocator>& b)
  641. {
  642.     a.swap(b);
  643. }
  644. #endif
  645.  
  646. template <class Key, class T, class Compare, class Allocator>
  647. inline bool operator== (const multimap<Key, T, Compare, Allocator>& x, 
  648.                         const multimap<Key, T, Compare, Allocator>& y)
  649. {
  650.     return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
  651. }
  652.  
  653. template <class Key, class T, class Compare, class Allocator>
  654. inline bool operator< (const multimap<Key, T, Compare, Allocator>& x, 
  655.                        const multimap<Key, T, Compare, Allocator>& y)
  656. {
  657.     return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
  658. }
  659.  
  660. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  661. template <class Key, class T, class Compare, class Allocator>
  662. inline bool operator!= (const multimap<Key,T,Compare,Allocator>& x, 
  663.                         const multimap<Key,T,Compare,Allocator>& y)
  664. {
  665.     return !(x == y);
  666. }
  667.  
  668. template <class Key, class T, class Compare, class Allocator>
  669. inline bool operator> (const multimap<Key,T,Compare,Allocator>& x, 
  670.                        const multimap<Key,T,Compare,Allocator>& y)
  671. {
  672.     return y < x;
  673. }
  674.  
  675. template <class Key, class T, class Compare, class Allocator>
  676. inline bool operator>= (const multimap<Key,T,Compare,Allocator>& x, 
  677.                         const multimap<Key,T,Compare,Allocator>& y)
  678. {
  679.     return !(x < y);
  680. }
  681.  
  682. template <class Key, class T, class Compare, class Allocator>
  683. inline bool operator<= (const multimap<Key,T,Compare,Allocator>& x, 
  684.                         const multimap<Key,T,Compare,Allocator>& y)
  685. {
  686.     return !(y <  x);
  687. }
  688.  
  689. template <class Key, class T, class Compare, class Allocator>
  690. void swap(multimap<Key,T,Compare,Allocator>& a, 
  691.           multimap<Key,T,Compare,Allocator>& b)
  692. {
  693.     a.swap(b);
  694. }
  695. #endif
  696.  
  697. #ifndef _RWSTD_NO_NAMESPACE
  698. }
  699. #endif
  700.  
  701. #pragma option pop
  702. #endif /* __STD_MAP__ */
  703.  
  704.